﻿
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
    <link href="/lib/easyui/default/easyui.css" rel="stylesheet" />
    <script type="text/javascript" src="/lib/easyui/jquery.easyui.min.js"></script>
</head>
<body style="background-color: white;">
    <div class="data-wrap" style="margin:5px;">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">
                <div class="input-group input-group-sm">
                    <label class="input-group-addon m5_l">余额：</label>
                    <label class="input-group-addon m5_l balance">0.00</label>
                </div>
            </div>
            <div class="pull-right">
                <form class="form-inline" id="formSearch" onsubmit="return false;">
                    <div class="input-group input-group-sm">
                        增加余额输入正整数、减少余额输入负整数(如：-1)
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon">金额：</label>
                        <input class="form-control wd125" name="balance" type="text" maxlength="9" autocomplete="off" placeholder="0.00">
                    </div>
                    <button type="button" class="btn btn-default btn-sm active" id="btnConfirm"> 确认</button>
                </form>
            </div>
        </div>
        <!--高级搜索结束-->
        <div class="data-easyui data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="easyui-datagrid" id="paymentInterfacelog" style="width:390px;"></table>
                </div>
            </div>
        </div>

    </div>
    
    <script type="text/javascript">
    var id;
    $(function () {
        id = FlashPay.Util.GetQueryString("id");
                init(id);

        balance(id);

        $("button[id='btnConfirm']").click(function () {

            var data = {
                paymentInterfaceID: id,
                balance: $("input[name='balance']").val()
            };

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/PaymentInterface/PaymentInterfaceBalance",
                data: data,
                success: function (response) {
                    if (response.success) {
                        $("input[name='balance']").val("")
                        cover.Remove();
                        FlashPay.UI.Tip_success("操作成功！");
                        init(id);
                        balance(id);
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning("操作失败！" + response.errorMessage);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });
        });
    });

    function init(id) {

        $("#paymentInterfacelog").datagrid({
            fit: false,
            loadMsg: '数据加载中，请稍后……',
            method: "post",
            border: true,
            url: "/PaymentInterface/PaymentInterfaceLog?id=" + id,
            height: 390,
            singleSelect: true,
            rownumbers: true,
            width: 760,
            frozenColumns: [[
                { field: 'createName', title: '操作人', width: 100, align: 'left' },
                { field: 'createDate', title: '操作时间', width: 130, align: 'left' }
            ]],
            columns: [[
                { field: 'logRemark', title: '备注', align: 'left' }
            ]]
        });

    }
    
    function balance(id) {
        FlashPay.Util.Ajax({
            type: "POST",
            url: "/PaymentInterface/GetPaymentInterface?id="+id,
            contentType: "application/json",
            success: function (res) {
                if (res.success) {
                    $("label.balance").html(res.data.balance);
                }
            }
        });
    }
    </script>
</body>
</html>